package com.yl.springbootrabbitmq.consumer;

import com.yl.springbootrabbitmq.config.ConfirmConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author yangl
 */
@Component
@Slf4j
public class Consumer {
    /**
     * 消费确认的消息
     * @param message
     */
    @RabbitListener(queues = ConfirmConfig.CONFIRM_QUEUE_NAME)
    public void receiveConfirmMsg(Message message){
        System.out.println(new String(message.getBody()));
        log.info("接收到的队列confirm.queue的消息：{}", new String(message.getBody()));
    }

    /**
     * 消费回退后的备份消息
     * @param message
     */
    @RabbitListener(queues = ConfirmConfig.BACKUP_QUEUE_NAME)
    public void receiveBackupMsg(Message message){
        System.out.println(new String(message.getBody()));
        log.info("接收到的备份的队列backup.queue的消息：{}", new String(message.getBody()));
    }
}
